#include<bits/stdc++.h>
#define er 0.000001
using namespace std;
int n,m,L,V;
int p[100009];//m
bool on[100009];//m
struct car{
    bool iscar;
    double s;
    double e;
};
car cars[100009];//n
bool cmp(car a,car b){
    return a.e<b.e;
}
car makecar(int d,int a,int v){
    car ans;
    double e,s;
    bool iscar=1;
    if(a>0){
        e=L+0.5;
        s=((V*V-v*v)/(2*a*1.0))+d;
        if(s+er>=e)
            iscar=0;
    }
    if(a==0){
        if(v<=V)
            iscar=0;
        e=L+0.5;
        s=d-0.5;
    }
    if(a<0){
        e=((V*V-v*v)/(2*a*1.0))+d;
        s=d-0.5;
        if(v<=V)
            iscar=0;
    }
    ans.iscar=iscar;
    ans.s=s;
    ans.e=e;
    return ans;
}
void solve(){
    int notcar=0;
    int pre=-1;
    int ans=m;
    for(int i=1;i<=n;i++){
        double e=cars[i].e,s=cars[i].s;
        if(!cars[i].iscar){
            notcar++;
            //cout<<":-1:"<<i;
            continue;
        }
        //cout<<':'<<s<<':'<<pre<<':'<<e<<',';
        if(e>pre&&pre>s){
            //cout<<":+:"<<i<<',';
            continue;
        }
        int ne;
        if(abs(cars[i].e-(int)(cars[i].e))<=er)
            ne=(int)(cars[i].e)-1;
        else
            ne=(int)(cars[i].e);
        int nxt=lower_bound(p+1,p+n+1,ne)-p;
        if(p[nxt]>ne)
            nxt--;
       // cout<<i<<':'<<ne<<':'<<nxt<<',';
        if(nxt>m)
            nxt=m;
        nxt=p[nxt];
        if(nxt-s<er){
            notcar++;
            //cout<<":-2:"<<i<<',';
            continue;
        }
        ans--;
        pre=nxt;
    }
    for(int i=1;i<=m;i++){
            ;
        //ans+=!on[i];
        //cout<<on[i]<<' ';
    }
    //cout<<endl;
    cout<<n-notcar<<' '<<ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>n>>m>>L>>V;
        for(int j=1;j<=n;j++){
            int di,vi,ai;
            cin>>di>>vi>>ai;
            cars[j]=makecar(di,ai,vi);
        }
        sort(cars+1,cars+n+1,cmp);
        for(int i=1;i<=n;i++){
                ;
            //cout<<':'<<cars[i].iscar<<' '<<cars[i].s<<' '<<cars[i].e<<endl;
        }
        for(int j=1;j<=m;j++){
            cin>>p[j];
            on[j]=0;
        }
        sort(p+1,p+n+1);
        p[0]=-1919810;
        on[0]=0;
        //    1000009
        solve();
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
